//
//  MessageProductCell.m
//  FFMall
//
//  Created by ale tan on 2017/10/11.
//  Copyright © 2017年 IT.Bear. All rights reserved.
//

#import "MessageProductCell.h"
#import <UIImageView+WebCache.h>

@interface MessageProductCell ()

@property (weak, nonatomic) IBOutlet UIImageView *productImageView;
@property (weak, nonatomic) IBOutlet UILabel *productBrandLabel;
@property (weak, nonatomic) IBOutlet UILabel *productNameLabel;
@property (weak, nonatomic) IBOutlet UILabel *sizeLabel;
@property (weak, nonatomic) IBOutlet UILabel *priceLabel;


@end

@implementation MessageProductCell

- (void)awakeFromNib {
    [super awakeFromNib];
    
    self.selectionStyle = UITableViewCellSelectionStyleNone;
}

- (void)loadWithModel:(FBProductModel *)model IndexPath:(NSIndexPath *)indexPath{
    //图片
    if (model.productCover) {
        [_productImageView sd_setImageWithURL:[NSURL URLWithString:model.productCover] placeholderImage:nil];
    }
    else if (model.cover) {
        [_productImageView sd_setImageWithURL:[NSURL URLWithString:model.cover] placeholderImage:nil];
    }
    else{
        _productImageView.image = nil;
    }
    
    //品牌
    if (model.designerName) {
        _productBrandLabel.text = model.designerName;
    }
    else{
        _productBrandLabel.text = [NSString stringWithFormat:@"咨询商品%ld",(long)indexPath.row+1];
    }
    
    //产品名称
    if (model.productName) {
        _productNameLabel.text = model.productName;
    }
    else{
        _productNameLabel.text = @"";
    }
    
    //尺码
    if (model.size) {
        _sizeLabel.text = [NSString stringWithFormat:@"尺码：%@",model.size];
    }
    else{
        _sizeLabel.text = @"";
    }
    
    //价格
    if (model.showPrice) {
        if (model.currencyLogo && model.currencyLogo.length) {
            _priceLabel.text = [NSString stringWithFormat:@"%@%@",model.currencyLogo,model.showPrice];
        }
        else{
            _priceLabel.text = [NSString stringWithFormat:@"¥%@",model.showPrice];
        }
    }
    else{
        _priceLabel.text = @"";
    }
    
    //数量
    _qtyLabel.hidden = NO;
    if (model.productQty) {
        _qtyLabel.text = [NSString stringWithFormat:@"x %@",model.productQty];
    }
    else{
        _qtyLabel.text = @"x 1";
    }
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
